home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / kopete / kopetechatsessionmanager.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-09-10  |  5.0 KB  |  193 lines

  1. /*
  2.     kopetechatsessionmanager.h - Creates chat sessions
  3.  
  4.     Copyright (c) 2002-2003 by Duncan Mac-Vicar Prett <duncan@kde.org>
  5.  
  6.     Kopete    (c) 2002-2003 by the Kopete developers  <kopete-devel@kde.org>
  7.  
  8.     *************************************************************************
  9.     *                                                                       *
  10.     * This library is free software; you can redistribute it and/or         *
  11.     * modify it under the terms of the GNU Lesser General Public            *
  12.     * License as published by the Free Software Foundation; either          *
  13.     * version 2 of the License, or (at your option) any later version.      *
  14.     *                                                                       *
  15.     *************************************************************************
  16. */
  17.  
  18. #ifndef KOPETEMESSAGEMANAGERFACTORY_H
  19. #define KOPETEMESSAGEMANAGERFACTORY_H
  20.  
  21. #include <qobject.h>
  22. #include <qptrlist.h>
  23. #include <qintdict.h>
  24. #include <qvaluelist.h>
  25.  
  26. #include "kopetechatsession.h"
  27. #include "kopetemessage.h"
  28.  
  29. #include "kopete_export.h"
  30.  
  31. class KopeteView;
  32.  
  33. namespace Kopete
  34. {
  35.  
  36. class Contact;
  37. class Protocol;
  38. class MessageEvent;
  39.  
  40. typedef QPtrList<Contact>        ContactPtrList;
  41. typedef QValueList<Message>      MessageList;
  42.  
  43. /**
  44.  * @author Duncan Mac-Vicar Prett <duncan@kde.org>
  45.  *
  46.  * Kopete::ChatSessionManager is responsible for creating and tracking Kopete::ChatSession
  47.  * instances for each chat.
  48.  */
  49. class KOPETE_EXPORT ChatSessionManager : public QObject
  50. {
  51.     Q_OBJECT
  52.  
  53. public:
  54.     static ChatSessionManager* self();
  55.  
  56.     ~ChatSessionManager();
  57.  
  58.     /**
  59.      * Create a new chat session. Provided is the initial list of contacts in
  60.      * the session. If a session with exactly these contacts already exists,
  61.      * it will be reused. Otherwise a new session is created.
  62.      * @param user The local user in the session.
  63.      * @param chatContacts The list of contacts taking part in the chat.
  64.      * @param protocol The protocol that the chat is using.
  65.      * @return A pointer to a new or reused Kopete::ChatSession.
  66.      */
  67.     Kopete::ChatSession* create( const Kopete::Contact *user,
  68.         Kopete::ContactPtrList chatContacts, Kopete::Protocol *protocol);
  69.  
  70.     /**
  71.      * Find a chat session, if one exists, that matches the given list of contacts.
  72.      * @param user The local user in the session.
  73.      * @param chatContacts The list of contacts taking part in the chat.
  74.      * @param protocol The protocol that the chat is using.
  75.      * @return A pointer to an existing Kopete::ChatSession, or 0L if none was found.
  76.      */
  77.     Kopete::ChatSession* findChatSession( const Kopete::Contact *user,
  78.         Kopete::ContactPtrList chatContacts, Kopete::Protocol *protocol);
  79.  
  80.     /**
  81.      * Registers a Kopete::ChatSession (or subclass thereof) with the Kopete::ChatSessionManager
  82.      */
  83.     void registerChatSession(Kopete::ChatSession *);
  84.  
  85.     /**
  86.      * Get a list of all open sessions.
  87.      */
  88.     QValueList<ChatSession*> sessions();
  89.  
  90.     /**
  91.      * @internal
  92.      * called by the kmm itself when it gets deleted
  93.      */
  94.     void removeSession( Kopete::ChatSession *session );
  95.  
  96.     /**
  97.      * create a new view for the manager.
  98.      * only the manager should call this function
  99.      */
  100.     KopeteView *createView( Kopete::ChatSession * , const QString &requestedPlugin = QString::null );
  101.  
  102.     /**
  103.      * Post a new event. this will emit the @ref newEvent signal
  104.      */
  105.     void postNewEvent(Kopete::MessageEvent*);
  106.  
  107.     /**
  108.      * Returns the current active Kopete view
  109.      */
  110.     KopeteView *activeView();
  111.  
  112. signals:
  113.     /**
  114.      * This signal is emitted whenever a message
  115.      * is about to be displayed by the KopeteChatWindow.
  116.      * Please remember that both messages sent and
  117.      * messages received will emit this signal!
  118.      * Plugins may connect to this signal to change
  119.      * the message contents before it's going to be displayed.
  120.      */
  121.     void aboutToDisplay( Kopete::Message& message );
  122.  
  123.     /**
  124.      * Plugins may connect to this signal
  125.      * to manipulate the contents of the
  126.      * message that is being sent.
  127.      */
  128.     void aboutToSend( Kopete::Message& message );
  129.  
  130.     /**
  131.      * Plugins may connect to this signal
  132.      * to manipulate the contents of the
  133.      * message that is being received.
  134.      *
  135.      * This signal is emitted before @ref aboutToDisplay()
  136.      */
  137.     void aboutToReceive( Kopete::Message& message );
  138.  
  139.     /**
  140.      * A new view has been created
  141.      */
  142.     void viewCreated( KopeteView * );
  143.  
  144.     /**
  145.      * A view as been activated(manually only?).
  146.      */
  147.     void viewActivated( KopeteView *view );
  148.  
  149.     /*
  150.      * A view is about to close.
  151.      */
  152.     void viewClosing( KopeteView *view );
  153.  
  154.     /**
  155.      * a new KMM has been created
  156.      */
  157.     void chatSessionCreated( Kopete::ChatSession *);
  158.  
  159.     /**
  160.      * the message is ready to be displayed
  161.      */
  162.     void display( Kopete::Message& message, Kopete::ChatSession * );
  163.  
  164.     /**
  165.      * A new event has been posted.
  166.      */
  167.     void newEvent(Kopete::MessageEvent *);
  168.  
  169.     /**
  170.      * The global shortcut for sending message has been used
  171.      */
  172.     void readMessage();
  173.  
  174. public slots:
  175.     void slotReadMessage();
  176.  
  177. private:
  178.     ChatSessionManager( QObject* parent = 0, const char* name = 0 );
  179.  
  180.     class Private;
  181.     Private *d;
  182.  
  183.     static ChatSessionManager *s_self;
  184.  
  185. };
  186.  
  187. }
  188.  
  189. #endif
  190.  
  191. // vim: set noet ts=4 sts=4 sw=4:
  192.  
  193.